home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Gophers / Gopher protocol / DRAFT Gopher FYI RFC.txt next >
Text File  |  1993-03-12  |  31KB  |  700 lines

  1. Network Working Group                                  F. Anklesaria
  2. FYI: ??                                                  M. McCahill
  3.                                                           P. Lindner
  4.                                                           D. Johnson
  5.                                                            D. Torrey
  6.                                              University of Minnesota
  7.                                                           March 1993
  8.  
  9.  
  10.              F.Y.I on the Internet Gopher Protocol
  11.       (a distributed document search and retrieval protocol)
  12.  
  13.  
  14.  
  15.  
  16.  
  17. Status of this Memo
  18. The Internet Gopher protocol is designed for distributed document 
  19. search and retrieval. This document describes the protocol, lists some 
  20. of the implementations currently available, and has an overview of how 
  21. to implement new client and server applications. This document is 
  22. adapted from the basic Internet Gopher protocol document first issued 
  23. by the Microcomputer Center at the University of Minnesota in 1991.  
  24. The distribution of this memo is unlimited.
  25.  
  26.  
  27. Abstract
  28. gopher  n.  1. Any of various short tailed, burrowing mammals of 
  29. the family Geomyidae, of North America.  2. (Amer. colloq.) 
  30. Native or inhabitant of Minnesota: the Gopher State.  3. (Amer. 
  31. colloq.) One who runs errands, does odd-jobs, fetches or 
  32. delivers documents for office staff.  4. (computer tech.) 
  33. software following a simple protocol for burrowing through a 
  34. TCP/IP internet.
  35.  
  36. The Internet Gopher protocol and software follow a client-server 
  37. model. This protocol assumes a reliable data stream; TCP is assumed. 
  38. Gopher servers should listen on port 70 (port 70 is assigned to 
  39. Internet Gopher by IANA).  Documents reside on many autonomous servers 
  40. on the Internet.  Users run client software on their desktop systems, 
  41. connecting to a server and sending the server a selector (a line of 
  42. text, which may be empty) via a TCP connection at a well-known port.  
  43. The server responds with a block of text terminated by a period on a 
  44. line by itself and closes the connection.  No state is retained by the 
  45. server.
  46.  
  47. While documents (and services) reside on many servers, Gopher client 
  48. software presents users  with a hierarchy of items and directories 
  49. much like a file system. The Gopher interface is designed to resemble 
  50. a file system since a file system is a good model for organizing 
  51. documents and services; the user sees what amounts to one big 
  52. networked information system containing primarily document items, 
  53. directory items, and search items (the latter allowing searches for 
  54. documents across subsets of the information base).
  55.  
  56. Servers return either directory lists or documents.  Each item in a 
  57. directory is identified by a type (the kind of object the item is), 
  58. user-visible name (used to browse and select from listings), an opaque 
  59. selector string (typically containing a pathname used by the 
  60. destination host to locate the desired object), a host name (which 
  61. host to contact to obtain this item), and an IP port number (the port 
  62. at which the server process listens for connections). The user only 
  63. sees the user-visible name.  The client software can locate and 
  64. retrieve any item by the trio of selector, hostname, and port.
  65.  
  66.  
  67. To use a search item, the client submits a query to a special kind of 
  68. Gopher server : a search server. In this case the client sends the 
  69. selector string (if any) and the list of words to be matched. The 
  70. response  yields "virtual directory listings" that contain items 
  71. matching the search criteria.  
  72.  
  73. Gopher servers and clients exist for all popular platforms.  Because 
  74. the protocol is so sparse and simple, writing servers or clients is 
  75. quick and straightforward.
  76.  
  77.  
  78.  
  79. 1.  Introduction
  80.  
  81. The Internet Gopher protocol is designed primarily to act as a 
  82. distributed document delivery system.  While documents (and services) 
  83. reside on many servers, Gopher client software presents users  with a 
  84. hierarchy of items and directories much like a file system.  In fact, 
  85. the Gopher interface is designed to resemble a file system since a 
  86. file system is a good model for locating documents and services. Why 
  87. model a campus-wide information system after a file system? Several 
  88. reasons:
  89.  
  90. (a) A hierarchical arrangement of information is familiar to many 
  91. users. Hierarchical  directories containing items (such as documents, 
  92. servers, and subdirectories)  are widely used in electronic bulletin 
  93. boards and other campus-wide information systems. People who access a 
  94. campus-wide information server will expect some sort of hierarchical 
  95. organization to the information presented. 
  96.  
  97. (b) A file-system style hierarchy can be expressed in a simple 
  98. syntax.   The syntax used for the internet Gopher protocol is easily 
  99. understandable, and was designed to make debugging servers and clients 
  100. easy. You can use Telnet to simulate an internet Gopher client's 
  101. requests and observe the responses from a server.  Special purpose 
  102. software tools are not required.  By keeping the syntax of the pseudo-
  103. file system client/server protocol simple, we can also achieve better 
  104. performance for a very common user activity: browsing through the 
  105. directory hierarchy.
  106.  
  107. (c) Since Gopher originated in a University setting, one of the 
  108. goals was for departments to have the option of publishing information 
  109. from their inexpensive desktop machines, and since much of the 
  110. information can be presented as simple text files arranged in 
  111. directories, a protocol modeled after a file system has immediate 
  112. utility. Because there can be a direct mapping from the file system on 
  113. the user's desktop machine to the directory structure published via 
  114. the Gopher protocol, the problem of writing server software for slow 
  115. desktop systems is minimized.
  116.  
  117. (d) A file system metaphor is extensible. By giving a "type" 
  118. attribute to items in the pseudo-file system, it is possible to 
  119. accommodate documents other than simple text documents. Complex 
  120. database services can be handled as a separate type of item. A file-
  121. system metaphor does not rule out search or database-style queries for 
  122. access to documents. A search-server type is also defined in this 
  123. pseudo-file system.  Such servers return "virtual directories" or list 
  124. of documents matching user specified criteria. 
  125.  
  126.  
  127.  
  128. 2.  The internet Gopher Model
  129.  
  130. A detailed BNF rendering of the internet Gopher syntax is available in 
  131. the appendix... but a close reading of the appendix may not be 
  132. necessary to understand the internet Gopher protocol. 
  133.  
  134. In essence, the Gopher protocol consists of a client connecting to a 
  135. server and sending the server a selector (a line of text, which may be 
  136. empty) via a TCP connection.  The server responds with a block of text 
  137. terminated with a period on a line by itself, and closes the 
  138. connection.  No state is retained by the server between transactions 
  139. with a client. The simple nature of the protocol stems from the need 
  140. to implement servers and clients  for the slow, smaller desktop 
  141. computers (1 MB Macs and DOS machines), quickly, and efficiently. 
  142.  
  143. Below is a simple example of a client/server interaction; more complex 
  144. interactions are dealt with later.   Assume that a "well-known" Gopher 
  145. server (this may be duplicated, details are discussed later) listens 
  146. at a well known port for the campus (much like a domain-name server).  
  147. The only configuration information the client software retains is this 
  148. server's name  and port number (in this example that machine is 
  149. rawBits.micro.umn.edu and the port 70). In the example below the 
  150. Δ character denotes the TAB character.
  151.  
  152. Client:          {Opens connection to rawBits.micro.umn.edu at port 70}
  153.  
  154. Server:          {Accepts connection but says nothing}
  155.  
  156. Client: <CR><LF> {Sends an empty line: Meaning "list what you have"}
  157.  
  158. Server:          {Sends a series of lines, each ending with CR LF}
  159. 0About internet GopherΔStuff:About usΔrawBits.micro.umn.eduΔ70
  160. 1Around the University of MinnesotaΔZ,5692,AUMΔunderdog.micro.umn.eduΔ70
  161. 1Microcomputer News & PricesΔPrices/Δpserver.bookstore.umn.eduΔ70
  162. 1Courses, Schedules, CalendarsΔΔevents.ais.umn.eduΔ9120
  163. 1Student-Staff DirectoriesΔΔuinfo.ais.umn.eduΔ70
  164. 1Departmental PublicationsΔStuff:DP:ΔrawBits.micro.umn.eduΔ70
  165.                    {.....etc.....}
  166. .                  {Period on a line by itself}
  167.                    {Server closes connection}
  168.  
  169. The first character on each line tells whether the line describes a 
  170. document, directory, or search service (characters '0', '1', '7'; 
  171. there are a handful more of these characters described later).  The 
  172. succeeding characters up to the tab form a user display string to be 
  173. shown to the user for use in selecting this document (or directory) 
  174. for retrieval.  The first character of the line is really defining the 
  175. type of item described on this line. In nearly every case, the Gopher 
  176. client software will give the users some sort of idea about what type 
  177. of item this is (by displaying an icon,  a short text tag, or the 
  178. like).
  179.  
  180. The characters following the tab, up to the next tab form a selector 
  181. string that  the client software must send to the server to retrieve 
  182. the document (or directory listing).  The selector string should mean 
  183. nothing to the client software; it should never be modified by the 
  184. client.   In practice, the selector string is often a pathname or 
  185. other file selector used by the server to locate the item desired.  
  186. The next two tab delimited fields denote the domain-name of the host 
  187. that has this document (or directory), and the port at which to 
  188. connect.  If there are yet other tab delimited fields, the basic 
  189. Gopher client should ignore them.  A CR LF denotes the end of the 
  190. item.
  191.  
  192. In the example, line 1 describes a document the user will see as 
  193. "About internet Gopher".  To retrieve this document, the client 
  194. software must send the retrieval string: "Stuff:About us" to 
  195. rawBits.micro.umn.edu at port 70.  If the client does this, the server 
  196. will respond with the contents of the document, terminated by a period 
  197. on a line by itself.  A client might present the user with a view of 
  198. the world something like the following list of items:
  199.  
  200.  
  201. About Internet Gopher
  202. Around the University of Minnesota...
  203. Microcomputer News & Prices...
  204. Courses, Schedules, Calendars...
  205. Student-Staff Directories...
  206. Departmental Publications...
  207.  
  208.  
  209. In this case, directories are displayed with an ellipsis and files are 
  210. displayed without any.  However, depending on the platform the client 
  211. is  written for and the author's taste, item types could be denoted 
  212. by other text tags or by icons.  For example, the UNIX curses-based
  213. client displays directories with a slash (/) following the name;
  214. Macintosh clients display directories alongside an icon of a folder.
  215.  
  216. The user does not know or care that the items up for selection may 
  217. reside on many different machines anywhere on the Internet.  
  218.  
  219. Suppose the user selects the line "Microcomputer News & Prices...".  
  220. This appears to be a directory, and so the user expects to see 
  221. contents of the directory upon request that it be fetched.  The 
  222. following lines illustrate the ensuing client-server interaction:
  223.  
  224.  
  225. Client:           (Connects to pserver.bookstore.umn.edu at port 70)
  226. Server:           (Accepts connection but says nothing)
  227. Client: Prices/   (Sends the magic string terminated by CRLF)
  228. Server:           (Sends a series of lines, each ending with CR LF)
  229. 0About PricesΔPrices/AboutusΔpserver.bookstore.umn.eduΔ70
  230. 0Macintosh PricesΔPrices/MacΔpserver.bookstore.umn.eduΔ70
  231. 0IBM PricesΔPrices/IckΔpserver.bookstore.umn.eduΔ70
  232. 0Printer & Peripheral PricesΔPrices/PPPΔpserver.bookstore.umn.eduΔ70
  233.                   (.....etc.....)
  234. .                 (Period on a line by itself)
  235.                   (Server closes connection)
  236.  
  237.  
  238. 3. More details
  239.  
  240. 3.1  Locating services
  241. Documents (or other services that may be viewed ultimately as 
  242. documents, such as a student-staff phonebook) are linked to the 
  243. machine they are on by the trio of selector string, machine domain-
  244. name, and IP port.  It is assumed that there will be one well-known 
  245. top-level or root server for an institution or campus.  The 
  246. information on this server may be duplicated by one or more other 
  247. servers to avoid a single point of failure and to spread the load over 
  248. several servers.  Departments that wish to put up their own 
  249. departmental servers need to register the machine name and port with 
  250. the administrators of the top-level Gopher server, much the same way 
  251. as they register a machine name with the campus domain-name server.  
  252. An entry which points to the departmental server will then be made at 
  253. the top level server.  This ensures that users will be able to 
  254. navigate their way down what amounts to a virtual hierarchical file 
  255. system with a well known root to any campus server if they desire.  
  256.  
  257. Note that there is no requirement that a department register secondary 
  258. servers with the central top-level server; they may just place a link 
  259. to the secondary servers in their own primary servers.  They may 
  260. indeed place links to any servers they desire in their own server, 
  261. thus creating a customized view of thethe Gopher information universe; 
  262. links can of course point back at the top-level server.  The virtual 
  263. (networked) file system is therefore an arbitrary graph structure and 
  264. not necessarily a rooted tree.  The top-level node is merely one 
  265. convenient, well-known point of entry.  A set of Gopher servers linked 
  266. in this manner may function as a campus-wide information system.
  267.  
  268. Servers may of course point links at other than secondary servers.  
  269. Indeed servers may point at other servers offering useful services 
  270. anywhere on the internet.  Viewed in this manner, Gopher can be seen 
  271. as an Internet-wide information system.
  272.  
  273.  
  274. 3.2 Server portability and naming
  275. It is recommended that all registered servers have alias names 
  276. (domain name system CNAME) that are used by Gopher clients to 
  277. locate them.  Links to these servers should use these alias names 
  278. rather than the primary names.  If information needs to be moved from 
  279. one machine to another, a simple change of domain name system alias 
  280. (CNAME) allows this to occur without any reconfiguration of clients in 
  281. the field.  In short,  the domain name system may be used to re-map a 
  282. server to a new address.  There is nothing to prevent secondary servers 
  283. or services from running on otherwise named servers or ports other than  
  284. 70, however these should be reachable via a primary server. 
  285.  
  286.  
  287. 3.3 Contacting server administrators
  288. It is recommended that every server administrator have a document 
  289. called  something like: "About Bogus University's Gopher server" as 
  290. the first item in their server's top level directory.  In this 
  291. document should be a short description of what the server holds, as 
  292. well as name, address, phone, and an e-mail address of the person who 
  293. administers the server.  This provides a way for users to get word to 
  294. the administrator of a server that has inaccurate information or is 
  295. not running correctly.  It is also recommended that administrators 
  296. place the date of last update in files for which such information 
  297. matters to the users.
  298.  
  299.  
  300. 3.4  Modular addition of services
  301. The first character of each line in a server-supplied directory 
  302. listing indicates whether the item is a file (character '0'),  a 
  303. directory (character '1'), or a search (character '7').  This is the 
  304. base set of item types in the Gopher protocol.  It is desirable for 
  305. clients to be able to use different services and speak different 
  306. protocols (simple ones such as finger; others such as CSO (qi) 
  307. phonebook service, or Telnet, or X.500 directory service) as needs 
  308. dictate.  For example if a server-supplied directory listing marks a 
  309. certain item with type character '2', then it means that to use this 
  310. item, the client must speak the CSO (qi) protocol.  This removes the 
  311. need to be able to anticipate all future needs and hard-wire them in 
  312. the basic Internet Gopher protocol; it keeps the basic protocol 
  313. extremely simple.  In spite of this simplicity, the scheme has the 
  314. capability to expand and change with the times by adding an agreed 
  315. upon type-character for a new service.  This also allows the client 
  316. implementations to evolve in a modular fashion, simply by dropping in 
  317. a module (or launching a new process) for some new service.  The 
  318. servers for the new service of course have to know nothing about 
  319. Internet Gopher; they can just be off-the shelf CSO, X.500, or other 
  320. servers.  We do not however, encourage arbitrary or machine-specific 
  321. proliferation of service types in the basic Gopher protocol.
  322.  
  323.  
  324. On the other hand, subsets of other document retrieval schemes may be 
  325. mapped onto the Gopher protocol by means of "gateway-servers".  
  326. Examples of such servers include Gopher-to-FTP gateways, Gopher-to-
  327. Archie gateways, Gopher-to-WAIS gateways,  etc.  There are a number of 
  328. advantages of such mechanisms. First, a relatively powerful server 
  329. machine inherits both the intelligence and work, rather than the more 
  330. modest, inexpensive desktop system that typically runs client software 
  331. or basic server software.  Equally important, clients do not have to 
  332. be modified to take advantage of a new resource.  
  333.  
  334.  
  335. 3.5  Building clients
  336. A client simply sends the retrieval string to a server if it wants to 
  337. retrieve a document or view the contents of a directory.  Of course, 
  338. each host may have pointers to other hosts, resulting in a "graph" 
  339. (not necessarily a rooted tree) of hosts.  The client software may 
  340. save (or rather "stack") the locations that it has visited in search 
  341. of a document.  The user could therefore back out of the current 
  342. location by unwinding the stack.  Alternatively, a client with 
  343. multiple-window capability might just be able to display more than one 
  344. directory or document at the same time.
  345.  
  346. A smart client could cache the contents of visited directories (rather 
  347. than just the directory's item descriptor), thus avoiding network 
  348. transactions if the information has been previously retrieved.
  349.  
  350. If a client does not understand what a say, type  'B' item (not a core 
  351. item) is, then it may simply ignore the item in the directory listing; 
  352. the user never even has to see it.  Alternatively, the item could be 
  353. displayed as an unknown type.  
  354.  
  355. Top-level or primary servers for a campus are likely to get more 
  356. traffic than secondary servers, and it would be less tolerable for 
  357. such primary servers to be down for any long time.  So it makes sense 
  358. to "clone" such  important servers and construct clients that can 
  359. randomly choose between two such equivalent primary servers when they 
  360. first connect (to balance server load), moving to one if the other 
  361. seems to be down.  In fact smart client implementations do this clone 
  362. server and load balancing. Alternatively, it may make sense to have
  363. the domain name system return one of a set of redundant of server's 
  364. IP address to load balance betwen redundant sets of important 
  365. servers.
  366.  
  367.  
  368. 3.6  Building ordinary internet Gopher servers
  369. The retrieval string sent to the server might be a path to a file or 
  370. directory.  It might be the name of a script,  an application or even 
  371. a query that generates the document or directory returned.  The basic 
  372. server uses the string it gets up to but not including a CR-LF or a 
  373. TAB, whichever comes first.
  374.  
  375. All intelligence is carried by the server implementation rather than 
  376. the protocol.  What you build into more exotic servers is up to you.    
  377. Server implementations may grow as needs dictate and time allows.
  378.  
  379.  
  380. 3.7  Special purpose servers
  381. There are two special server types (beyond the normal Gopher server) 
  382. also discussed below: 
  383.  
  384.  
  385.     1.  A  server directory listing can point at a CSO (qi)
  386.     nameserver  (the server returns a type character of '2')
  387.     to allow a campus  student-staff phonebook lookup
  388.     service.  This may show up on the  user's list of
  389.     choices, perhaps preceded by the icon of a phone-book.  
  390.     If this item is selected, the client software must resort
  391.     to a pure  CSO nameserver protocol when it connects to
  392.     the appropriate host.
  393.  
  394.  
  395.     2.  A server can also point at a "search server" (returns
  396.     a first  character of '7').  Such servers may implement
  397.     campus network (or  subnet) wide searching capability. 
  398.     The most common search servers  maintain full-text
  399.     indexes on the contents of text documents held by  some
  400.     subset of Gopher servers.  Such a "full-text search
  401.     server"  responds to client requests with a list of all
  402.     documents that contain  one or more words (the search
  403.     criteria).  The client sends the server  the selector
  404.     string, a tab, and the search string (words to search 
  405.     for). If the selector string is empty, the client merely
  406.     sends the  search string.  The server returns the
  407.     equivalent of a directory  listing for documents matching
  408.     the search criteria.  Spaces between  words are usually
  409.     implied Boolean ANDs (although in different 
  410.     implementations or search types, this may not necessarily
  411.     be true). 
  412.  
  413.  
  414. The CSO addition exists for historical reasons: at time of design, the 
  415. campus phone-book servers at the University of Minnesota used the CSO 
  416. protocol and it seemed simplest to just engulf them.  The index-server 
  417. is however very much a Gopher in spirit, albeit with a slight twist in 
  418. the meaning of the selector-string. Index servers are a natural place
  419. to incorperate gateways to WAIS and WHOIS services.
  420.  
  421.  
  422. 3.7.1  Building CSO-servers
  423. A CSO Nameserver implementation for UNIX and associated documentation 
  424. is available by anonymous ftp from uxa.cso.uiuc.edu.  We do not 
  425. anticipate implementing it on other machines.
  426.  
  427.  
  428. 3.7.2  Building full-text search servers
  429. A full-text search server is a special-purpose server that knows 
  430. about the Gopher scheme for retrieving documents.  These servers 
  431. maintain a full-text index of the contents of plain text documents on 
  432. Gopher servers in some specified domain.  A  Gopher full-text search 
  433. server was implemented using several NeXTstations because it was easy 
  434. to take advantage of the full-text index/search engine built into the 
  435. NeXT system software.  A search server for generic UNIX systems based 
  436. on the public domain WAIS search engine, is also available and 
  437. currently an optional part of the UNIX gopher server. In addition, at
  438. least one implementation of the gopher server incorperates a gateway
  439. to WAIS servers by presenting the WAIS servers to gopherspace as 
  440. full-text search servers. The gopher<->WAIS gateway servers does the
  441. work of translating from gopher protocol to WAIS so unmodified gopher 
  442. clients can access WAIS servers via the gateway server.
  443.  
  444. By using several index servers (rather than a monolithic index server) 
  445. indexes may be searched in parallel (although the client software is 
  446. not aware of this). While maintaining full-text indexes of documents 
  447. distributed over many machines may seem a daunting task, the task can 
  448. be broken into smaller pieces (update only a portion of the indexes, 
  449. search several partial indexes in parallel) so that it is manageable. 
  450. By spreading this task over several small, cheap (and fast) 
  451. workstations it is possible to take advantage of fine-grain 
  452. parallelism. Again, the client software is not aware of this. Client 
  453. software only needs to know that it can send a search string to an 
  454. index server  and will receive a list of documents that contain the 
  455. words in the search string. 
  456.  
  457. 3.8  Item type characters
  458. The client software decides what items are available by looking at the 
  459. first character of each line in a directory listing.   Augmenting this 
  460. list  can extend the protocol.  A list of defined item-type characters 
  461. follows:
  462.  
  463. 0   Item is a file
  464. 1   Item is a directory
  465. 2   Item is a CSO (qi) phone-book server
  466. 3   Error
  467. 4   Item is a BinHexed Macintosh file.
  468. 5   Item is DOS binary archive of some sort.
  469.     Client must read until the TCP connection closes.  Beware.
  470. 6   Item is a UNIX uuencoded file. 
  471. 7   Item is an Index-Search server.
  472. 8   Item points to a text-based telnet session.
  473. 9   Item is a binary file!
  474.     Client must read until the TCP connection closes.  Beware.
  475. +   Item is a redundant server
  476. T   Item points to a text-based tn3270 session.
  477. g   Item is a GIF format graphics file.
  478. I   Item is some kind of image file.  Client decides how to display.
  479.  
  480.  
  481. Characters '0' through 'Z'  are reserved.  Local experiments 
  482. should use other characters.  Machine-specific extensions are 
  483. not encouraged.  Note that for type 5 or type 9 the client must 
  484. be prepared to read until the connection closes.  There will be 
  485. no period at the end of the file; the contents of these files 
  486. are binary and the client must decide what to do with them based 
  487. perhaps on the .xxx extension.
  488.  
  489.  
  490. 3.9  User display strings and server selector strings
  491. User display strings are intended to be displayed on a line on a 
  492. typical screen for a user's viewing pleasure.  While many screens can 
  493. accommodate 80 character lines, some space is needed to display a tag 
  494. of some sort to tell the user what sort of item this is. Because of 
  495. this, the user display string should be kept under 70 characters in 
  496. length.  Clients may truncate to a length convenient to them.
  497.  
  498.  
  499. 4   Simplicity is intentional
  500.  
  501. As far as possible we desire any new features to be carried as new 
  502. protocols that will be hidden behind new document-types.    The 
  503. internet Gopher philosophy is: 
  504.  
  505.     (a) Intelligence is held by the server.  Clients have
  506.     the option of  being able to access new document types
  507.     (different, other types of  servers) by simply
  508.     recognizing the document-type character.   Further
  509.     intelligence to be borne by the protocol should be 
  510.     minimized.
  511.     
  512.     (b) The well-tempered server ought to send "text"
  513.     (unless a file must  be transferred as raw binary). 
  514.     Should this text include tabs,  formfeeds, frufru? 
  515.     Probably not, but rude servers will probably  send them
  516.     anyway.  Publishers of documents should be given simple 
  517.     tools (filters) that will alert them if there are any
  518.     funny  characters in the documents they wish to publish,
  519.     and give them the  opportunity to strip the questionable
  520.     characters out; the publisher  may well refuse.
  521.     
  522.     (c) The well-tempered client should do something
  523.     reasonable with funny  characters received in text;
  524.     filter them out, leave them in,  whatever.
  525.  
  526.  
  527.  
  528.  
  529.                            Appendix.
  530.  
  531.            Paul's NQBNF (Not Quite BNF) for the Gopher Protocol.
  532.  
  533. Note:  This is modified BNF (as used by the Pascal people) with a few
  534.        English modifiers thrown in.  Stuff enclosed in '{}' can be
  535.        repeated zero or more times.  Stuff in '[]' denotes a set of
  536.        items.  The '-' operator denotes set subtraction.
  537.  
  538.  
  539. Directory Entity
  540.  
  541. CR-LF     ::= ASCII Carriage Return Character followed by Line Feed
  542.               character. 
  543.  
  544. Tab       ::= ASCII Tab character.
  545.  
  546. NUL       ::= ASCII NUL character.
  547.  
  548. UNASCII   ::= ASCII - [Tab CR-LF NUL].
  549.  
  550. Lastline  ::= '.'CR-LF.
  551.  
  552. TextBlock ::= Block of ASCII text not containing Lastline pattern.
  553.  
  554. Type      ::= UNASCII.
  555.  
  556. RedType   ::= '+'.
  557.  
  558. User_Name ::= {UNASCII}.
  559.  
  560. Selector  ::= {UNASCII}.
  561.               
  562. Host      ::= {{UNASCII - ['.']} '.'} {UNASCII - ['.']}.
  563.               
  564. Note: This is a Fully Qualified Domain Name as defined in RFC 830.
  565.       (e.g. gopher.micro.umn.edu)  Hosts that have a CR-LF
  566.       TAB or NUL in their name get what they deserve.
  567.  
  568. Digit     ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' .
  569.  
  570. DigitSeq  ::= digit {digit}.
  571.  
  572. Port      ::= DigitSeq.
  573.  
  574. Note: Port corresponds the the TCP Port Number, its value should
  575.       be in the range [0..65535]; port 70 is officially assigned
  576.       to gopher.
  577.  
  578. DirEntity ::= Type User_Name Tab Selector Tab Host Tab Port CR-LF 
  579.           {RedType User_Name Tab Selector Tab Host Tab Port CR-LF}
  580.  
  581.  
  582.  
  583. Notes:
  584.  
  585.    It is *highly* recommended that the User_Name field contain only
  586.    printable characters, since many different clients will be using
  587.    it.  However if eight bit characters are used, the characters
  588.    should conform with the ISO Latin1 Character Set.  The length of
  589.    the User displayable line should be less than 70 Characters; longer
  590.    lines may not fit across some screens.
  591.  
  592.    The Selector string should be no longer than 255 characters. 
  593.  
  594.  
  595. Menu Entity
  596.  
  597. Menu      ::= {DirEntity} Lastline.
  598.  
  599.  
  600. Menu Transaction  (Type 1 item)
  601.  
  602. C: Opens Connection
  603. S: Accepts Connection
  604. C: Sends Selector String
  605. S: Sends Menu Entity
  606.  
  607.    Connection is closed by either client or server (typically server).
  608.  
  609.  
  610. Textfile Entity
  611.  
  612. TextFile  ::= {TextBlock} Lastline
  613.  
  614. Note:  Lines beginning with periods must be prepended with an extra 
  615.      period to ensure that the transmission is not terminated early. 
  616.      The client should strip extra periods at the beginning of the line.
  617.  
  618.  
  619. TextFile Transaction (Type 0 item)
  620.  
  621. C: Opens Connection.
  622. S: Accepts connection
  623. C: Sends Selector String.
  624. S: Sends TextFile Entity.
  625.  
  626.    Connection is closed by either client or server (typically server).
  627.  
  628. Note:  The client should be prepared for the server closing the
  629.        connection without sending the Lastline.  This allows the
  630.        client to use fingerd servers.
  631.  
  632.  
  633. Full-Text Search Transaction (Type 7 item)
  634.  
  635. Word      ::= {UNASCII - ' '}
  636. BoolOp ::= 'and' | 'or' | 'not' | SPACE
  637. SearchStr ::= Word {{SPACE BoolOp} SPACE Word}
  638.  
  639. C: Opens Connection.
  640. C: Sends Selector String, Tab, Search String.
  641. S: Sends Menu Entity.
  642.  
  643. Note:  In absence of 'and', 'or', or 'not' operators, a SPACE is 
  644.        regarded as an implied 'and' operator.  Expression is evaluated
  645.        left to right.  Further, not all search engines or search gateways
  646.        currently implemented have the boolean operators implemented.
  647.  
  648. Binary file Transaction (Type 9 or 5 item)
  649.  
  650. C: Opens Connection.
  651. S: Accepts connection
  652. C: Sends Selector String.
  653. S: Sends a binary file and closes connection when done.
  654.  
  655.  
  656. Syntactic Meaning for Directory Entities
  657.  
  658.  
  659. The client should interpret the type field as follows:
  660.  
  661. 0   The item is a TextFile Entity. 
  662.     Client should use a TextFile Transaction.
  663.  
  664. 1   The item is a Menu Entity.  
  665.     Client should use a Menu Transaction. 
  666.  
  667. 2   The information applies to a CSO phone book entity.
  668.     Client should talk CSO protocol.
  669.  
  670. 3   Signals an error condition.
  671.  
  672. 4   Item is a Macintosh file encoded in BINHEX format
  673.  
  674. 5   Item is PC-DOS binary file of some sort.  Client gets to decide.
  675.  
  676. 6   Item is a uuencoded file.
  677.  
  678. 7   The information applies to a Index Server.  
  679.     Client should use a FullText Search transaction.
  680.  
  681. 8   The information applies to a Telnet session. 
  682.     Connect to given host at given port. The name to login as at this
  683.     host is in the selector string.
  684.  
  685. 9   Item is a binary file.  Client must decide what to do with it.
  686.  
  687. +   The information applies to a duplicated server.  The information 
  688.     contained within is a duplicate of the primary server.  The primary
  689.     server is defined as the last DirEntity that is has a non-plus
  690.     "Type" field.  The client should use the transaction as defined by 
  691.     the primary server Type field.
  692.     
  693. g   Item is a GIF graphic file.
  694.  
  695. I   Item is some kind of image file.  Client gets to decide.
  696.  
  697. T   The information applies to a tn3270 based telnet session. 
  698.     Connect to given host at given port. The name to login as at this
  699.     host is in the selector string.
  700.